package com.huak.zookeeper.connection;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.CountDownLatch;

/**
 * @author liuhuan
 * @date 2018/9/16 10:21
 * @description
 */
@Slf4j
@Data
public abstract  class BaseDangeCenter implements Runnable {

    private CountDownLatch countDownLatch;//计数器

    private String station ;//调度站

    private boolean ok; //调度站检查当前的调度状态是否ok

    public BaseDangeCenter(CountDownLatch countDownLatch,String station){
        this.countDownLatch=countDownLatch;
        this.station=station;
        this.ok=ok;
    }


    @Override
    public void run() {
        try{
            check();
            ok=true;
        }catch (Exception e){
            log.error(e.getMessage(),e);
            ok=false;
        }finally {
            if (countDownLatch!=null){
                countDownLatch.countDown();
            }
        }
    }

    /**
     * 检查问题
     */
    public abstract void check();
}
